<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Full Layout - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="/resource/css/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="/resource/css/themes/icon.css">
	<!--<link rel="stylesheet" type="text/css" href="../demo.css">-->
	<script type="text/javascript" src="/resource/js/jquery.min.js"></script>
	<script type="text/javascript" src="/resource/js/jquery.easyui.min.js"></script>
</head>

<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px">north region</div>
	<div data-options="region:'west',split:true,title:'主要菜单'" style="width:150px;padding:10px;">
			
	</div>
	
	<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">south region</div>
	<div data-options="region:'center',title:'Center'">
		<form id="ff-bizInfo" class="custom-form" method="post">
			<table cellpadding="5" align="center" width="80%">
				
				<div style="padding:5px 0;">
					<a href="javascript:generateSalt();" class="easyui-linkbutton" data-options="iconCls:'icon-add'">生成盐值</a>
					<a href="javascript:getPassword();" class="easyui-linkbutton" data-options="iconCls:'icon-save'">生成密码</a>					
				</div>
				<tr>
					<td style="text-align: right;width: 15%">用户名称:</td>
					<td style="text-align: left;width: 35%"><input class="easyui-textbox" type="text" name="username" id="username" data-options="required:true" style="width:100%"/></td>
					<td style="text-align: right;width: 15%">用户编码:</td>
					<td style="text-align: left;width: 35%"><input class="easyui-textbox" type="text" name="uid" id="uid" data-options="required:true" style="width:100%"/></td>			
				</tr>		

				<tr>
					<td style="text-align: right;width: 15%">用户密码:</td>
					<td style="text-align: left;width: 35%"><input class="easyui-textbox" type="text" name="password" id="password" data-options="required:true" style="width:100%"/></td>
					
					
				</tr>
				<tr>
					
					<td style="text-align: right;width: 15%">密码盐值:</td>
					<td style="text-align: left;width: 35%"><input class="easyui-textbox" type="text" name="salt" id="salt" style="width:100%"/></td>
					<td style="text-align: right;width: 15%">生成密码:</td>
					<td style="text-align: left;width: 35%"><input class="easyui-textbox" type="text" name="saltpassword" id="saltpassword" data-options="required:true" style="width:100%"/></td>
					
				</tr>
				
				

			</table>
			
		</form>
	</div>
</body>
<script>
	function generateSalt(){
		$.post("/biz/generateSalt", null, function(rsp) {
				if(rsp){
					var saltTxt = $('#salt')
					$(saltTxt).textbox('setValue',rsp);
				}
			}).error(function() {
				$.messager.alert("提示", "获取盐值出错,请刷新页面!");
			});
	}
	
	function getPassword(){
		var uname = $('#username').val;
		var password = $('#password').val;
		var salt = $('#salt').val;
		var uid = $('#uid').val;
		
		if(uname&&uname!=null&&uname!=""){
			if(password&&password!=null&&password!=""){
				if(salt&&salt!=null&&salt!=""){
					$.post("/biz/generatePassword", {loginname:uname,password:password,salt:salt,uid:uid}, function(rsp) {
						if(rsp)
							$('#saltpassword').textbox('setValue',rsp);
					}).error(function() {
						$.messager.alert("提示", "获取密码出错,请刷新页面!");
					});
				}
			}
		}
			
	}
	
</script>
</html>